﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iHub
{
    public partial class specbatch : Form
    {
        public specbatch()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Form_Closing);
        }

        private void Form_Closing(object sender, FormClosingEventArgs e){
            if (e.CloseReason == CloseReason.UserClosing)
            {
                DialogResult msg = MessageBox.Show("Closing this window will list all affected items to batch number 0. Continue?","Proceed",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);

                if (msg == DialogResult.Yes)
                {
                    importedfile.batchno = "";
                }
                else if(msg == DialogResult.No)
                {
                    e.Cancel = true;
                }
            }
        }

        private void enterval_Click(object sender, EventArgs e)
        {
            try
            {
                if (!batchno.Text.Equals(""))
                {
                    importedfile.batchno = batchno.Text;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Please enter a value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString(), "Fatal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
